home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 7461 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  6.7 KB

  1. Path: dnt.dialog.com!news
  2. From: Paul Gorodyansky <paul_gorodyansky@corp.dialog.com>
  3. Newsgroups: comp.lang.pl1,comp.lang.c
  4. Subject: Re: PL/I and C
  5. Date: Mon, 26 Feb 1996 11:18:15 -0800
  6. Organization: Knight-Ridder Information, Inc.
  7. Message-ID: <31320777.2810@corp.dialog.com>
  8. References: <4gh5ru$eng@goanna.cs.rmit.EDU.AU> <4gn5d8$t5f@newsbf02.news.aol.com> <4gril3$sn9@goanna.cs.rmit.EDU.AU>
  9. NNTP-Posting-Host: pc3046.corp.dialog.com
  10. Mime-Version: 1.0
  11. Content-Type: text/plain; charset=iso-8859-2
  12. Content-Transfer-Encoding: 7bit
  13. X-Mailer: Mozilla 2.0 (Win16; I)
  14.  
  15. As I said, I just found out that my posting went also to
  16.  comp.lang.C group, in addition to PL/I group.
  17.  
  18. So, I'll be more careful and post only to a specific group, because
  19. OUR talk was about *mainframe* C vs. PL/I, and MOREOVER, about
  20. *business* applications, involving heavy Text Processing, not about
  21. *systems* programming.                   ---------------
  22.  
  23.  Again, in *business* applications *Production* environment, where 
  24.    - to be 'closer to Specs',
  25.    - to be 'easy to read' and
  26.    - 'easy to maintain' 
  27.    - 'quicker to fix'
  28.  is Vital, PL/I is MUCH better than C.
  29.  
  30.    All you, C guys who replied, paid TOO MUCH attention to my note
  31. about UNIONS, but it's a MINOR thing compared to other AWFUL for
  32. an *application* programmer  things in C that I listed.
  33. In systems/low-level tasks C may be Perfect.
  34.  
  35. After so many replies that did not quote these MAJOR things, I am
  36. posting to comp.lang.C group LAST time, repeating the items, that,
  37. in my opinion, make C a *bad* choice for
  38.   an *application* Production environment,
  39.   where Fix time is *critical*,
  40.   where are MANY (not ONE package for market) *different* programs,
  41.   OFTEN to be changed due to Specs changes,
  42.   often by several engineers, who may see *this* program and
  43.   *this* data(Huge) FIRST time and have COUPLE hours to fix it.
  44.  
  45.    It is known that C is lower  level language that PL/I, 
  46. it's closer to Assembly. Nothing wrong with it, moreover, 
  47. it's why C programs usually are much more efficient.
  48.  
  49.    BUT 'there is no free lunch' and this effectiveness causes
  50. LESS readability.  
  51. PL/I is reacher, so it's is easier to implement things there and
  52. make a code more readable.
  53.  
  54. Just 2 examples of our NORMAL, REGULAR code (nothing special).
  55.  
  56. I. Select/Switch statement. 
  57. ----------------------- 
  58.   This important part of ANY *application* program is VERY
  59.         ------- 
  60.    rudimental and hard to use in C - you can use ONLY numbers here:
  61.  
  62. switch(my_choice) { 
  63.   case 0:  
  64. ....
  65.   break;
  66.  case 1: 
  67. ....    
  68.   break;
  69. }
  70.  
  71. You can use Enumerations in C but they are still only NUMBERS.
  72.                                                       -------
  73.  In PL/I you can use any Expression (!) as a switch, that makes a
  74.  code close to specs and easy to read and modify:
  75.       --------------     ------------     ------               
  76.  
  77. Select(Source_Tag);
  78.   When( 'AN' )
  79.         ..... 
  80.   When ( 'PD', 'PY', 'SO' )
  81.          ... 
  82.   When 
  83.          ...
  84.   When
  85.          ...
  86. End;
  87.  
  88.     or something like that
  89.  
  90. Select;                                                         
  91.   When ( SUBSTR(INREC,4,1) = ' ' ) 
  92.        ....                                                           
  93.   When
  94.        ...
  95.   When ( INDEX(UPALPHA,Cur_Tag) > 0  &                           
  96.          VERIFY(W_TAG23,'0123456789') = 0 )                     
  97.        ....
  98.   When ( String_1 || String_2 = String_3 )
  99.         ...                                                       
  100. End; 
  101.  
  102. It is how SPECIFICATIONS look like, so for a person who works 
  103. with this program  FIRST time, it is CLEAR, after reading specs,
  104. what this part of code is doing.
  105.      Just TRY to implement it in C !!!
  106. You will HAVE TO find some 'work around', so it will be further
  107.                                                         ------ 
  108. from specs and the piece of the code will be much BIGGER and LESS 
  109. clear, harder to understand.
  110.  
  111.    And NUMEROUS parts of C REQUIRE similar 'work around' while PL/I
  112. has such features in it.
  113.  
  114. Just another example. Strings.
  115.  
  116.    C has this VERY STUPID limitation - a 'string' in C it's a set of
  117. bytes with x'00' at the end ! 
  118. But, we have x'00' all over our source data !
  119. For example, we have on-line European Patent Office data (only ONE of
  120. our 400+ *different* applications), and source file is 40 gigabytes (!)
  121. FULL of x'00' !!!
  122.  
  123.     Also, C does not have Variable Length Strings, that are VERY
  124. important for our *application* programs. Again, this feature helps to
  125. have programs SHORTER, more READABLE, and CLOSER to specs.
  126.  
  127.   And talking about Readability, ++robin (Feb 26) has some good points:
  128.  > The basic operations of string-handling are done somewhat
  129.  > clumsily in C -- catenation is a simple infix operation
  130.  > in PL/I, but you must use a function in C, and then it
  131.  > catentates the second operand to the first. 
  132.  > Nothing like PL/I's c = d || e;
  133.  > (And what happens when, in strcat(s1, s2), the sum of the lengths
  134.  > of s1 and s2 exceeds the declaration for s1?!?!?
  135.  
  136. NEED WORK AROUND AGAIN !!! Code is BIGGER and LESS CLEAR.
  137.  
  138.  > again, for comparison, IF s1 > s2 THEN . . .  becomes
  139.  > strcmp(s1, s2) . . . which yields neg, 0, or pos . . .
  140.  > which leads to IF strcmp(s1, s2) > 0 . . .
  141.  > which is scarcely intuitive [shades of the arcane FORTRAN
  142.  > arithmetic IF].
  143.  
  144.     And now imagine how IT (foo-o-o) looks in OUR programs, where
  145. due to this STUPID x'00' limitation, we even can not use THESE
  146. (not very friendly) functions, and MUST use operations on
  147. BUFFERS, i.e. mem.. functions, taking through a code Length of
  148. buffers all the time ! 
  149.    Same Program in PL/I is 100 times more readable and is 100 times
  150. more easy to CHANGE and FIX.
  151.  
  152. So, my points are the following.
  153.   Open Systems people very often tell that *only* C
  154. should be used EVERYWHERE, and it's wrong - you never go to
  155. a farmer's field with a handbag, and to a food store with a truck -
  156. tasks are different, and some can be done better with C,
  157. and some - with PL/I.
  158.  
  159.    For *application* programming *Production* environment with a lot 
  160. of Text Processing, and a lot of *different* and often *changed* 
  161.    ---------------                               -----
  162. programs, PL/I is MUCH, MUCH better than C:             
  163.  - PL/I has wider set of statements, so it is much easier in PL/I
  164.    to make a code be CLOSE to specs, so next person will understand
  165.    a code faster and can FIX program faster;
  166.  - if a language REQUIRES workaround OFTEN, then it is LESS readable 
  167.    than another language that is reacher.
  168.  
  169. P.S. If you need more language specific information in regards
  170.       to functionality, performance, etc., then read article by
  171.       Eberhard Sturm ( GUIDE & SHARE Conference, 1994 )
  172.           "Power Vs Adventure - PL/I and C".        WWW address is:
  173. http://www.uni-muenster.de/URZ/Mitarbeiter/EberhardSturm/PL1andC.html
  174.  
  175. -- 
  176. Paul Gorodyansky      mailto:paul_gorodyansky@corp.dialog.com
  177.